package com.gxa.user.recycling.service.impl;

import com.gxa.core.recycling.common.ExceptionCode;
import com.gxa.core.recycling.exception.BusinessException;
import com.gxa.core.recycling.pojo.CommunityManage;
import com.gxa.core.recycling.service.impl.BaseServiceImpl;
import com.gxa.user.recycling.mapper.CommunitymanagesMapper;
import com.gxa.user.recycling.service.CommunityManagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service("communityManagesService")
@Transactional(rollbackFor = {Throwable.class})
public class CommunityManagesServiceImpl extends BaseServiceImpl<CommunityManage> implements CommunityManagesService {
    @Autowired
    CommunitymanagesMapper communitymanagesMapper=null;
    @Override
    public List<CommunityManage> selectBy(String provinces) throws BusinessException {
        List<CommunityManage> communityManages = communitymanagesMapper.selectBy(provinces);
        if(communityManages==null){
            throw new BusinessException(ExceptionCode.XIAOQU_NULL);
        }
        return communityManages;
    }

    @Override
    public CommunityManage selectByNameGetCommunity(String provinces,String name) throws BusinessException {
        CommunityManage communityManage = communitymanagesMapper.selectByNameGetCommunity(provinces,name);
        if(communityManage==null){
            throw new BusinessException(ExceptionCode.NOFIND_XIAOQU);
        }
        return communityManage;
    }

}
